#include <iostream>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
using namespace std;

int main()
{
    pid_t id = fork();
	if (id == 0)
	{
		sleep(3);
		execl("/usr/bin/ls", "ls", "-l", nullptr);
		exit(1);
	}

	pid_t rid = waitpid(id, nullptr, 0);//阻塞等待
	if (rid > 0)
	{
		cout << "等待子进程成功" << endl;
	}
	//execl("/usr/bin/ls", "ls", "-l", nullptr);
	return 0;
}

